package com.yc.spring.bank;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;

import javax.sql.DataSource;

@Configuration
@ComponentScan("com.yc.spring.bank")
public class jdbcConfig {

    @Bean
    DataSource dataSource(){
        DriverManagerDataSource  driverManagerDataSource;
        driverManagerDataSource = new DriverManagerDataSource();
        driverManagerDataSource.setDriverClassName("com.mysql.jdbc.Driver");
        driverManagerDataSource.setUrl("jdbc:mysql:///bank?useSSL=false");
        driverManagerDataSource.setUsername("root");
        driverManagerDataSource.setPassword("a001");
        return driverManagerDataSource;

    }
    @Bean
    JdbcTemplate jdbcTemplate(DataSource dataSource){
        return  new JdbcTemplate(dataSource);

    }


}
